Ten ways a page can be interactive

Every demo below works. Nothing is loaded from the internet. Press ? for the shortcuts, / to jump to the search box.

01

Tabs

JavaScript

One panel visible at a time. Click a tab, or focus one and use the arrow keys.

Tabs save space when the content splits cleanly into a few views that are rarely needed at once.
02

Accordion

No JavaScript

Built on the native <details> element. The browser handles opening and closing.

What it is
Sections that expand one at a time, with no script at all.
When to use it
Long reference content where the reader wants one answer, not the whole page.
What to watch
Content inside a closed section is still on the page, so it is still searchable and printable.
03

Split pane

JavaScript

Drag the divider to resize. Double-click it to go back to an even split.

LeftDrag the grey bar. The two widths always add up to the full width, so nothing overflows.
RightPointer events make this work with a mouse, a trackpad and touch, all from the same code.
Split: 50 / 50
04

Keyboard shortcuts

JavaScript

Press any key to see it captured. / focuses search, ? opens the shortcut sheet, Esc closes things.

Last key: none yet
05

Modal and drawer

JavaScript

A dialog takes over the page; a drawer slides in beside it. Both close on Esc or a click outside.

06

Tooltip and popover

Mostly CSS

A tooltip appears on hover and explains. A popover needs a click and stays until dismissed.

Gross margin was 38.2% this quarter.

Gross profit divided by revenue, before operating costs. Click anywhere else to dismiss this.
07

Drag and drop

JavaScript

Drag a row to reorder the list. The blue edge shows where it will land.

  • ⋮⋮Collect requirements
  • ⋮⋮Draft the model
  • ⋮⋮Review with finance
  • ⋮⋮Publish the dashboard
Order:
08

Live filter and sort

JavaScript

Type to filter as you go. Click a column heading to sort, click again to reverse it.

CityRegion UnitsRevenue
09

Inline edit

JavaScript

Click a value to edit it where it sits. Enter saves, Esc cancels, clicking away saves.

OwnerAsha Menon Target1,600 Cr Review date24 October
10

Form validation

JavaScript

Feedback as you type, a strength meter, and a submit button that stays off until the form is valid.

Keyboard shortcuts

/Focus the search box
?Open and close this sheet
EscClose the sheet, the modal or the drawer
← →Move between tabs, when a tab has focus

Press Esc or click outside to close.

A real dialog

This uses the browser's own <dialog> element, so focus is trapped and Esc works without any code from me.